home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
FREENET
/
MELL
/
NETLIB00
/
NetLib
/
c
/
netof
< prev
next >
Wrap
Text File
|
1995-02-28
|
602b
|
34 lines
#include "arpa/inet.h"
#include "netinet/in.h"
/*
* Extract a network number from an internet address
*/
u_long inet_netof(struct in_addr in)
{
u_long net;
if (IN_CLASSA(in.s_addr))
{
/* Extract a class A network number */
net = in.s_addr & IN_CLASSA_NET;
}
else if (IN_CLASSB(in.s_addr))
{
/* Extract a class B network number */
net = in.s_addr & IN_CLASSB_NET;
}
else if (IN_CLASSC(in.s_addr))
{
/* Extract a class C network number */
net = in.s_addr & IN_CLASSC_NET;
}
else
{
/* Not a known address format */
net = 0;
}
return net;
}